<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <%@ include file="/common/header.jsp" %>
        <%--<link href="<%=basePath %>/plug/dhtmlxTree/codebase/dhtmlxtree.css" rel="stylesheet" type="text/css"/>--%>
        <title>合同信息</title>
    </head>
    <body>
      <div id="dialog"></div>
        <table style="width:50%;height:100px;">
            <tr>
                <td align="right">
                    合同编号：
                    <input type="text" id="contractCode"/>
                </td>
                <td align="right">
                    用户ID：
                    <input type="text" id="userId"/>
                </td>
                <td align="right">签订时间:
                    <input type="text" id="signTimeStart" class="easyui-datetimebox" editable="false" />
                </td>
                <td align="right">至:
                    <input type="text" id="signTimeEnd" class="easyui-datetimebox" editable="false"/>
                </td>
                <td>
                    <a href="" target="_blank"></a>
                    <button id="search" onclick="search()">查询</button>
                </td>
            </tr>
        </table>

        <div id="dataGrid" style="width:100%;"/>

    <script>
        $("#dataGrid").datagrid({
            url: "<%=basePath%>/viewContract/queryList",
            loadMsg: "正在查询数据...",
            width: $(window).width()*0.99,
            height: $(window).height()*0.85,
            pagination: true,
            singleSelect:true,
            pageSize:15,
            pageList :[15,20,25],
            columns: [
                [
                    {field: 'id', title: '序号',fit:true, align: 'center'},
                    {field: 'contractCode', title: '合同编号',fit:true, align: 'center'},
                    {field: 'userId', title: '用户ID',width:70, fit:true,fit:true, align: 'center'},
                    {field: 'contractTemplateCode', title: '合同模板ID',  fitColumns:true,fit:true,  align: 'center'},
                    {field: 'borrowId', title: '标ID',  fitColumns:true,fit:true,  align: 'center'},
                    {field: 'passCode', title: '通道编码', fit:true,fit:true, align: 'center'},
                    {field: 'merchantNo', title: '商户号', fit:true, align: 'center'},
                    {field: 'contractTitle', title: '合同标题', fit:true, align: 'center'},
                    {field: 'status', title: '状态', fit:true, align: 'center'},
                    {field: 'isArchives', title: '是否可归档', fit:true, align: 'center'},
                    {field: 'insertTime', title: '签约时间', fit:true, align: 'center'},
                    {field: 'contractDownloadUrl', title: '合同下载',
                        formatter:function (value, row,index) {
                            if (value != null){
                                return '<a href='+value+'  target="_blank">下载</a>';
                            }
                        }
                    },
                    {field: 'contractViewUrl', title: '合同查看',
                        formatter:function (value, row, index) {
                            if(value != null){
                                return '<a href='+value+' target="_blank">查看</a>';
                            }
                        }
                    }
                ]
            ],
            onLoadSuccess:function(data){
                if (data.errorMsg){
                    $.messager.alert('错误',data.errorMsg);
                }
            },
            onLoadError:function(){
                $.messager.alert('错误',"错误");
            }
        });
        
        function search() {
            var signTimeStart = $('#signTimeStart').datetimebox("getValue");
            var signTimeEnd = $('#signTimeEnd').datetimebox("getValue");
            var contractCode = $("#contractCode").val();
            var userId = $("#userId").val();

            $('#dataGrid').datagrid('reload', {
                step : "step",
                signTimeStart : signTimeStart,
                signTimeEnd : signTimeEnd,
                contractCode : contractCode,
                userId : userId
            });
        }
</script>
</body>
</html>